package operations;

import bookList.Book;
import bookList.BookList;

import java.util.Objects;
import java.util.Scanner;

/**
 * The type Borrow operations.
 *
 * @author CY
 * @date 2022 /08/09 23:42
 */
public class BorrowOperations implements Operations {
    @Override
    public void work(BookList bookList) {
        System.out.println("借阅书籍！");
        System.out.println("请输入你要借阅的书名：");
        Scanner sc = new Scanner(System.in);
        String name = sc.nextLine();
        for (Book book : bookList.getBooks()) {
            if (Objects.equals(name, book.getName())) {
                System.out.println("借阅成功，请按时归还！");
                book.setBorrowed(true);
                System.out.println();
                return;
            }
        }
        System.out.println("对不起，没有找到这本书！");
        System.out.println();
    }

}
